package be.tihh.mgmt.tasks;

import javax.swing.*;
import java.util.HashMap;
import java.util.Map;

public class TaskStatus {

    public static final String IDLE = "IDLE";
    public static final String RUNNING = "RUNNING";
    public static final String FINISHED_PREFIX = "FINISHED";
    public static final String FINISHED_OK  = FINISHED_PREFIX + "_OK";
    public static final String FINISHED_NOK = FINISHED_PREFIX + "_NOK";

    private Map<String, Icon> icons = new HashMap<String, Icon>();

    private String status;
    private String standardOutput;
    private String errorOutput;

    public TaskStatus() {
        status = IDLE;
        initIcons();
    }

    private void initIcons() {
        icons.put(IDLE, new ImageIcon("res\\icons\\cog.png"));
        icons.put(RUNNING, new ImageIcon("res\\icons\\cog_go.png"));
        icons.put(FINISHED_OK, new ImageIcon("res\\icons\\tick.png"));
        icons.put(FINISHED_NOK, new ImageIcon("res\\icons\\cross.png"));
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getStandardOutput() {
        return standardOutput;
    }

    public void setStandardOutput(String standardOutput) {
        this.standardOutput = standardOutput;
    }

    public String getErrorOutput() {
        return errorOutput;
    }

    public void setErrorOutput(String errorOutput) {
        this.errorOutput = errorOutput;
    }

    public Icon getIcon(){
        return icons.get(status);
    }

    @Override
    public String toString() {
        return status;
    }
}
